package com.zzq.my.jetpacks.jectpackapp.ui.act

import android.view.View
import androidx.fragment.app.Fragment
import by.kirich1409.viewbindingdelegate.viewBinding
import com.aisier.architecture.base.BaseActivity
import com.jennifer.andy.androidxlazyload.demo.adapter.FragmentLazyPagerAdapter
import com.jennifer.andy.androidxlazyload.demo.adapter.FragmentLazyStatePageAdapter
import com.zzq.my.jetpacks.jectpackapp.*
import com.zzq.my.jetpacks.jectpackapp.databinding.Activity1Binding
import com.zzq.my.jetpacks.jectpackapp.databinding.Activity3Binding
import com.zzq.my.jetpacks.util.loadFragments
import com.zzq.my.jetpacks.util.showHideFragment

/**
 * 描述：- Activity + Fragment
 * 作者：zhuangzeqin
 * 时间: 2022/1/18-17:04
 * 邮箱：zzq@eeepay.cn
 * 备注:
 */
class Activity3 : BaseActivity(R.layout.activity_3), View.OnClickListener {
    private val binding by viewBinding(Activity3Binding::bind)
    private lateinit var fragmentsMap: Map<String, Fragment>

    /**
     * 初始化数据
     */
    override fun initData() {
        fragmentsMap = generate123Fragments()
        loadFragments(binding.flContainer.id,0,*fragmentsMap.values.toTypedArray())
    }

    /**
     * 初始化操作
     */
    override fun initView() {

    }

    /**
     * 初始化点击事件操作
     */
    override fun eventOnClick() {
        binding.btn1.setOnClickListener(this)
        binding.btn2.setOnClickListener(this)
        binding.btn3.setOnClickListener(this)

    }

    override fun onClick(v: View) {
        when (v.id) {
            binding.btn1.id -> {
                showHideFragment(fragmentsMap.getValue(FRAGMENT_ONE))
            }
            binding.btn2.id -> {
                showHideFragment(fragmentsMap.getValue(FRAGMENT_TWO))
            }
            binding.btn3.id -> {
                showHideFragment(fragmentsMap.getValue(FRAGMENT_THREE))
            }
        }
    }
}